Conditions | 1 |
Paths | 2 |
Total Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* globals confirm, atob, btoa, alert */ |
||
16 | function options($window, state, savegame) { |
||
17 | let ct = this; |
||
18 | ct.state = state; |
||
19 | |||
20 | ct.reset = function(ask) { |
||
21 | let confirmation = true; |
||
22 | if (ask) { |
||
23 | confirmation = confirm('Are you sure you want to reset? This will permanently erase your progress.'); |
||
24 | } |
||
25 | |||
26 | if (confirmation === true) { |
||
27 | localStorage.removeItem('player'); |
||
28 | savegame.initSave(); |
||
29 | } |
||
30 | }; |
||
31 | |||
32 | ct.importSave = function(player) { |
||
33 | if (state.export) { |
||
34 | try { |
||
35 | state.player = JSON.parse(atob(state.export)); |
||
36 | savegame.versionControl(); |
||
37 | } catch (error) { |
||
38 | alert('Invalid save file.'); |
||
39 | } |
||
40 | } |
||
41 | }; |
||
42 | |||
43 | ct.exportSave = function(player) { |
||
44 | let exportText = btoa(JSON.stringify(player)); |
||
45 | let blob = new Blob([exportText], { |
||
|
|||
46 | type: 'text/plain' |
||
47 | }); |
||
48 | let url = $window.URL || $window.webkitURL; |
||
49 | let fileUrl = url.createObjectURL(blob); |
||
50 | let a = document.createElement('a'); |
||
51 | a.href = fileUrl; |
||
52 | a.download = "nucleogenesis-save.txt"; |
||
53 | a.click(); |
||
54 | url.revokeObjectURL(fileUrl); |
||
55 | }; |
||
56 | } |
||
57 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.